import { _decorator, Component, Node } from 'cc';
import { BasePanel } from './BasePanel';
import { BaseGame } from '../games/BaseGame';
import { _game, _platform } from '../Main';
import { MergeDish } from '../games/MergeDish';
import { GameState } from '../managers/GameManager';
const { ccclass, property } = _decorator;

@ccclass('MDUnlockPanel')
export class MDUnlockPanel extends BasePanel {

    panelName: string = '解锁'
    
    video() {
        let game: BaseGame = _game.game
        if (!(game instanceof MergeDish)) {
            return
        }
        if (!game.isInGameState(GameState.Gaming)) {
            return
        }
        if (game.curSlot >= game.maxSlot) {

            this.close()
            return
        }
        this.close(() => {
            _platform.platform.showVideo(() => {
                game.unlock()
            }, () => {
    
            })
        })
    }
}


